unit DuplicataRecSearchFr;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  ExtCtrls, Buttons, StdCtrls, EditBtn, MainSearchFr;

type

  { TDuplicataRecSearchFrame }

  TDuplicataRecSearchFrame = class(TMainSearchFrame)
    BitBtn1: TBitBtn;
    data_vencimento: TDateEdit;
    id_cliente: TEdit;
    id_duplicata_receber: TEdit;
    nome_pessoa: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    status: TRadioGroup;
    procedure BitBtn1Click(Sender: TObject);
    procedure LocalizarButtonClick(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

implementation

uses Initializator, QueryConditions, DuplicataReceberDM, MainFr;

{ TDuplicataRecSearchFrame }

procedure TDuplicataRecSearchFrame.LocalizarButtonClick(Sender: TObject);
var
  condicoes: TQueryConditions;
  valor: string;
begin
  if (status.ItemIndex = 0) then begin
    valor := 'A';
  end else if (status.ItemIndex = 1) then begin
    valor := 'Q';
  end else if (status.ItemIndex = 2) then begin
    valor := 'C';
  end;
  condicoes := TQueryConditions.Create(CON_AND);
  condicoes.AddJoinField('dr.id_cliente', 'p.id_pessoa');
  condicoes.Add('dr.id_duplicata_receber', id_duplicata_receber.Text);
  condicoes.Add('dr.id_cliente', id_cliente.Text);
  condicoes.AddText('p.nome_pessoa', nome_pessoa.Text);
  condicoes.Add('dr.status', valor);
  condicoes.Add('dr.data_vencimento', data_vencimento.Text);
  DuplicataReceberData.Search(Condicoes, 'duplicata_receber as dr, pessoa as p');
end;

procedure TDuplicataRecSearchFrame.BitBtn1Click(Sender: TObject);
begin
  TheControl.ShowForeignFrame(TMainFrame(ClienteSearchFrame));
end;

initialization
  {$I duplicatarecsearchfr.lrs}

end.
